package org.example;

import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        // 模拟 adb ls -lh 命令输出
        List<String> lsOutput = Arrays.asList(
                "-rw-rw---- 1 u0_a227 media_rw   56 2023-11-27 08:00 log.txt",
                "drwxrws--- 2 u0_a227 media_rw 3.3K 2022-12-27 22:26 taopai"
        );

        String remotePath = "/storage/emulated/0/DCIM";
        List<String> stringList = AdbUtil.listFilesOnDevice(remotePath);

        try {
            List<FileInfo> files = LsOutputParser.parseLsOutput(stringList);
            for (FileInfo fileInfo : files) {
                System.out.println(fileInfo);
            }

            Stack<String> stack = new Stack<>();

            for (FileInfo fileInfo : files) {
                System.out.println(fileInfo.getFileName());
                if (fileInfo.isDirectory()) stack.push(fileInfo.getFileName());
            }
            if (stack.isEmpty()) return;
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
